import 'package:cloud_medicine/components/user_avatar.dart';
import 'package:flutter/material.dart';

// 帖子评论者的组件
class AuthorShow extends StatefulWidget {
  final String avatar; // 作者头像
  final String realname; // 作者真实姓名
  final String createTime; // 创建时间
  Widget widget; // 右边部件
  final double imageStyle; // 图片样式大小
  final int userID; // 用户ID

  AuthorShow({
    Key key,
    @required this.userID,
    @required this.avatar,
    @required this.realname,
    @required this.createTime,
    this.imageStyle = 50,
    this.widget,
  }) : super(key: key);

  @override
  _AuthorShowState createState() => _AuthorShowState();
}

class _AuthorShowState extends State<AuthorShow> {
  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: <Widget>[
        Row(
          children: <Widget>[
            UserAvatar(
              userID: widget.userID,
              avatar: widget.avatar,
              imageStyle: widget.imageStyle,
            ),
            SizedBox(width: 5),
            Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(widget.realname),
                SizedBox(height: 5),
                Text(
                  widget.createTime,
                  style: TextStyle(color: Colors.grey),
                )
              ],
            )
          ],
        ),
        widget.widget ?? Container()
      ],
    );
  }
}
